/**
 * 商户端接入js库 5.0 兼容 4.0
 * 有些三方系统  或者 个别方法  调用没有生效的话  可以把 相应的 JSON.stringify(cfg)  换成 cfg  即可
 * 
 * 4.0升级5.0 三方js说明
 * 
 * jsbridge-1.0.4.js  是新加的js  目的是升级5.0用到的
 * thirdPayAll.js  是4.0和5.0公用的方法，做了兼容处理。
 * 具体操作：先引入jsbridge-1.0.4.js再引入thirdPayAll.js即可（最好把原有的4.0复制到thirdPayAll.js 的 else 里）， 
 * 如果第三方是拿到thirdPayAll.js 改写的 需要在里面找到对应的方法重新改写即可。
 * 如果原先使用的方法在thirdPayAll.js中没有，和我们反馈 我们再处理，可能部分方法有遗漏。
 * 引入之后，安卓4.0/5.0 苹果4.0/5.0  共4个版本都需要重新测试。
 * 
 * 把原有的4.0 thirdPay.js中对应的方法复制到thirdPayAll.js 的同名方法的 if(ThirdApp.versionFiveFlag){}else{}  的else 中。
 * 
 */
var ThirdApp = {
	os : null,
	cbName: "",
	appVersion : 0,
	versionFiveFlag : true,
	/**
	 * @private
	 * @description 调用客户端方法
	 * @param {string}
	 *            funcName 方法名，js与客户端约定
	 * @param {string}
	 *            jsonData 传递参数
	 */
	_callHandler : function(funcName, jsonData) {
		window.WebViewJavascriptBridge.callHandler(funcName, jsonData);
	},
	
	idSeed : 10000,
	/**
	 * @description 获取唯一id
	 * @returns {string} id
	 * @example var _id = YT.id();
	 */
	id : function() {
		return 'yt_gen_' + (++ThirdApp.idSeed);
	},
	/**
	 * @description 转换为字符
	 * @param {Object}
	 *            v 转换对象
	 * @returns {string} 返回字符串
	 * @example var str = YT.toString({STATUS:"1"});
	 */
	toString : function(v) {
		return Object.prototype.toString.apply(v);
	},
	/**
	 * @description 是否是数组
	 * @param {*}
	 *            v 值
	 * @returns {*|boolean} 是否为数组
	 * @example var arry = [];
	 * var isArray = YT.isArray(arry);
	 */
	isArray : function(v) {
		return ThirdApp.toString(v) === '[object Array]';
	},
	/**
	 * @description 是否为空
	 * @param {*}
	 *            v 值
	 * @param {boolean}
	 *            allowBlank 是否允许空
	 * @returns {*|boolean} 是否为空
	 * @example var obj;
	 * var isEmpty = YT.isEmpty(obj);
	 */
	isEmpty : function(v, allowBlank) {
		return v === null || v === undefined
				|| String(v).toUpperCase() === 'NULL'
				|| ((ThirdApp.isArray(v) && !v.length))
				|| (!allowBlank ? v === '' : false);
	},
	/**
	 * @description 判断值是否已定义
	 * @param {*}
	 *            v 判断对象
	 * @returns {*|boolean} 是否已定义
	 * @example var fun;
	 * var isDefined = YT.isDefined(fun);
	 */
	isDefined : function(v) {
		return typeof v !== 'undefined';
	},
	
	/**
	 * @description 是否是对象
	 * @param {*}
	 *            v 值
	 * @returns {*|boolean} 是否为对象
	 * @example var obj = {};
	 * var isObject = YT.isObject(obj);
	 */
	isObject : function(v) {
		return !!v && ThirdApp.toString(v) === '[object Object]';
	},
	
	/**
	 * @description 是否可迭代
	 * @param {*}
	 *            v 值
	 * @returns {*|boolean} 是否可迭代
	 * @example var arry = []; 
	 * var isIterable = YT.isIterable(arry);
	 */
	isIterable : function(v) {
		return (v && typeof v !== 'string') ? ThirdApp.isDefined(v.length) : false;
	},
	
	/**
	 * @description 是否是数值型
	 * @param {*}
	 *            v 值
	 * @returns {*|boolean} 是否为数值
	 * @example var b = 1;
	 * var isNumber = YT.isNumber(b);
	 */
	isNumber : function(v) {
		return typeof v === 'number' && ThirdApp.isFinite(v);
	},
	/**
	 * @description 是否是字符型
	 * @param {*}
	 *            v 值
	 * @returns {*|boolean} 是否为字符串
	 * @example var str = "test";
	 * var isString = YT.isString(str);
	 */
	isString : function(v) {
		return typeof v === 'string';
	},
	/**
	 * @description 是否是布尔型
	 * @param {*}
	 *            v 值
	 * @returns {*|boolean} 是否为布尔型
	 * @example var bool = true;
	 * var isBoolean = YT.isBoolean(bool);
	 */
	isBoolean : function(v) {
		return typeof v === 'boolean';
	},
	
	/**
	 * @description 是否是原始类型
	 * @param {*}
	 *            v 值
	 * @returns {*|boolean} 是否为原始类型
	 * @example var bool = true; 
	 * var isPrimitive = YT.isPrimitive(bool);
	 */
	isPrimitive : function(v) {
		return ThirdApp.isString(v) || ThirdApp.isNumber(v) || ThirdApp.isBoolean(v);
	},
	
	/**
	 * @description 遍历数组
	 * @param {*}
	 *            value 遍历对象
	 * @param {function}
	 *            fn 遍历处理函数
	 * @param {*}
	 *            scope 作用域
	 * @example YT.each(['a','b'],function(v,i){
	 * 	console.info(i+'-'+v);
	 * });
	 */
	each : function(value, fn, scope) {
		if (ThirdApp.isEmpty(value)) {
			return;
		}
		if (!ThirdApp.isDefined(scope)) {
			scope = value;
		}
		if (ThirdApp.isObject(value)) {
			var i = 0;
			for ( var prop in value) {
				if (value.hasOwnProperty(prop)) {
					if (fn.call(scope || value, prop, value[prop], i++, value) === false) {
						return;
					}
				}
			}
		} else {
			if (!ThirdApp.isIterable(value) || ThirdApp.isPrimitive(value)) {
				value = [ value ];
			}
			for (var i = 0, len = value.length; i < len; i++) {
				if (fn.call(scope || value[i], value[i], i, value) === false) {
					return i;
				}
			}
		}
	},
	
	/**
	 * @description String转换为JSON
	 * @param {string}
	 *            str json字符串
	 * @returns {Object} json对象
	 * @example YT.JsonEval('{"STATUS":"1"}');
	 */
	JsonEval : function(str) {
		return eval("(" + str + ")");
	},
	
	/**
	 * @description 获取方法名称
	 * @param {function}
	 *            func 方法对象
	 * @param {boolean}
	 *            decodeURL 是否转码，如果该函数的接收参数中包含URL，则该参数需要置为true
	 * @returns {*} 临时方法名
	 * @example cfg.success = YT.getFunctionName(cfg.success);
	 * 临时函数调用：
	 * window[cfg.success]&&window[cfg.success]();
	 */
	getFunctionName : function(func, decodeURL) {
		if (func == null || func == "") {
			return "";
		}
		if (Object.prototype.toString.apply(func) !== '[object Function]') {
			return func;
		}
		var funcName = ThirdApp.id();
		// 创建可被调用的临时方法
		window[funcName] = function() {
			var args = [];
			ThirdApp.each(arguments, function(arg) {
				if (true == decodeURL) {
					arg = decodeURIComponent(arg);
				}
				if ('string' == typeof arg && '{' == arg.charAt(0)
						&& '}' == arg.charAt(arg.length - 1)) {
					arg = ThirdApp.JsonEval(arg.replace(/<\/?[^>]*>/g, '').replace(
							/[\r\n]/g, '<br>'));
				}
				args.push(arg);
			}, this);
			func.apply(this, args);
			delete window[funcName];// 删除临时方法
		};
		return funcName;
	},
	
	/**
	 * @description 获取版本号<br>
	 * @param {function}
	 *         callback 回调函数名称
	 * @example YT.Client.getVersion(callback);
	 */
	getVersion : function(callback) {
			var cfg={
					callback : ThirdApp.getFunctionName(callback),
			};
			ThirdApp._callHandler("getVersion", JSON.stringify(cfg));
	},
	
	 getVersion4 : function(callback){
	        if (ThirdApp.os == 'android') {
	         window.SysClientJs.getVersion(callback);
	        } else if (ThirdApp.os == 'iphone') {
	            _WK_DATAS["getVersion"] = {
	            	callBack : callback
	          };
	    setWebitEvent("_getVersion()", "A7");
	     }
	    },

	/**
	 * 返回到一级菜单界面 5.0 by kangl
	 * 
	 */
	toHomePage : function() {
		if(ThirdApp.versionFiveFlag){
			try {
				ThirdApp._callHandler("gotoIndex", {});
			} catch (e) {
				ThirdApp.alertinfo('返回首页异常','gotoIndex:' + e);
			}
		}else{
			if (ThirdApp.os == 'android') {
				window.SysClientJs.getHome('goHome()','');
			} else if (ThirdApp.os == 'iphone') {
				_WK_DATAS["toHomePage"] = {};
				setWebitEvent("_toHomePage()", "B4");				
			}
		}
	},
	
	/**
	 * @description 返回上一页<br>
	 *              接口名称：gotoBack <br>
	 * @example YT.Client.gotoIndex();
	 */
	gotoBack : function() {
		try {
			ThirdApp._callHandler("gotoBack", {});
		} catch (e) {
			ThirdApp.alertinfo('返回上一页异常', 'gotoBack:' + e);
		}
	},
	
	/**
	 * @description 获取核心客户号<br> 5.0 by kangl
	 * *
	 * @example YT.Client.getcoreCustNo(callback);
	 */
	getCoreCustNo:function(url,merFlag){
		if(ThirdApp.versionFiveFlag){
			try {
				var cfg={
						url : url,
						flag : "1",
				};
				ThirdApp._callHandler("getThirdLoginInfo", JSON.stringify(cfg));
			} catch (e) {
				ThirdApp.alertinfo('调转第三方商城异常', 'getThirdLoginInfo:' + e);
			}
		}else{
			if (ThirdApp.os == 'android') {
				if(merFlag == undefined || merFlag == null || merFlag == ""){
					window.SysClientJs.getCoreCustNo(url);
				}else{
					window.SysClientJs.getToken(url,merFlag);
				}
			} else if (ThirdApp.os == 'iphone') {
				var data = {
						'url' : url,
						'flag' : '1' ,//第三方调用登陆标示(useless)	
				};
				if(merFlag == undefined || merFlag == null || merFlag == ""){
				}else{
					data.merFlag = merFlag;
				}
				_WK_DATAS["thirdLogin"] = data;
				
				setWebitEvent('_getThirdLoginInfo()', 'A1');
			}
		}
		
	},
	/**
	 * 5.0 没找到对应方法 ??
	 */
	getUserInfo: function(cb,m){
		if(ThirdApp.versionFiveFlag){
			var url = "common/getUserInfo.do?m="+m;
			var cfg={
					url:url,
					callback:cb,
				}
			ThirdApp._callHandler("post", JSON.stringify(cfg));
		}else{
			var url = "/common/paramGet.do?act=getUserInfo&m="+m;
			if (ThirdApp.os == 'android') {
				window.SysClientJs.WebReqInfo(url,cb);
			} else if (ThirdApp.os == 'iphone') {
				setWebitEvent("ThirdApp._getUserInfo('" + cb +"','" + url + "')", "JSB20");
			}
		}
	},
	_getUserInfo: function(cb,url){
		return ThirdApp.toJsonStr({url: url,callback:cb});
	},
	/**
	 * 支付接口，上送json格式字符串   5.0 by kangl
	 * @param jsonDataStr
	 */
	thirdPay : function(jsonDataStr) {
		if(ThirdApp.versionFiveFlag){
			try {
				var cfg={
						data:jsonDataStr,
				};
				ThirdApp._callHandler("saveThirdPayData", JSON.stringify(cfg));
			} catch (e) {
				ThirdApp.alertinfo('第三方支付数据保存本地异常', 'saveThirdPayData:' + e);
			}
			
		}else{
			if (ThirdApp.os == 'android') {
				window.SysClientJs.thirdPay(jsonDataStr);
			} else if (ThirdApp.os == 'iphone') {
				_WK_DATAS["thirdPay"] = jsonDataStr;
				setWebitEvent('_getThirdPayInfo()', 'A2');// 支付函数
			}
		}
		
	},

	/**
	 * 打开通讯录，用户选择号码后，回调callBack(mobileNo);  5.0 by kangl
	 * 
	 * @param callBack
	 *            函数的字符串名称
	 */
	getContact : function(callBack) {
		if(ThirdApp.versionFiveFlag){
			try {
				callBack = ThirdApp.getFunctionName(callBack);
				var cfg = {
					'callback' : callBack
				};
				ThirdApp._callHandler("showAddressBook", JSON.stringify(cfg));
			} catch (e) {
				ThirdApp.alertinfo('打开手机电话薄异常' , 'openPhoneBook:' + e);
			}
		}else{
			if (ThirdApp.os == 'android') {
				window.SysClientJs.getContact(callBack);
			} else if (ThirdApp.os == 'iphone') {
				_WK_DATAS["getContact"] = {
					'callback' : callBack
				};
				setWebitEvent("_getContact()", "37");
			}
		}
	},

	/**
	 * 打开等待层  5.0 by kangl
	 */
	showWaitPanel : function(msg) {
		if(ThirdApp.versionFiveFlag){
			var cfg = {
					msg : msg,
					touchable : 'false',
					type : 'OPEN'
				};
			ThirdApp._callHandler("showWaitPanel", JSON.stringify(cfg));
		}else{
			if (ThirdApp.os == 'android') {
				window.SysClientJs.showWaitPanel("加载中...");
			} else if (ThirdApp.os == 'iphone') {
				_WK_DATAS["wait"] = {
					'msg' : '加载中...',
					'callback' : '',
					'touchable' : 'false'
				};
				setWebitEvent('showWaitPanel()', '04');
			}
		}
	},

	/**
	 * 隐藏等待层 5.0 by kangl
	 */
	hideWaitPanel : function(timeout) {
		if(ThirdApp.versionFiveFlag){
			var cfg = {
					type : 'CLOSE'
				};
				setTimeout(function() {
					ThirdApp._callHandler("hideWaitPanel", JSON.stringify(cfg));
				}, timeout);
		}else{
			if (ThirdApp.os == 'android') {
				window.SysClientJs.hideWaitPanel();
			} else if (ThirdApp.os == 'iphone') {
				setWebitEvent('closeWaitPanel()', '04');
			}
		}
	},
	
	/**
	 * 初始化标题 5.0 by kangl
	 */
	initTitleInfo : function(pageId) {
		if(ThirdApp.versionFiveFlag){
			try {
				var json = this._getPageTitle(pageId);
				ThirdApp._callHandler("initPageTitle", JSON.stringify(json));
			} catch (e) {
				ThirdApp.alertinfo('初始化页标题栏异常', 'initPageTitle:' + e);
			}
		}else{
			if (ThirdApp.os == 'android') {
				var json = ThirdApp._getPageTitle(pageId);
				window.SysClientJs.updateTitleInfo(ThirdApp.toJsonStr(json));
			} else if (ThirdApp.os == 'iphone') {
				setWebitEvent("ThirdApp._getPageTitle('" + pageId + "')", "02");
			}
		}
	},
	/**
	 * 移除原生头部标题   5.0 by kangl
	 */
	removeNativeTitle: function(){
		if(ThirdApp.versionFiveFlag){
			 try {
				 var json = {
							title : "0",
							leftButton: {
								exist : "false",
								name : "",
								func : ""
							},
							rightButton: {
								exist : "false",
								name : "",
								func : ""
							},
							rightButton2: {
								exist : "false",
								name : "",
								func : ""
							}
						};
				 ThirdApp._callHandler("initPageTitle", JSON.stringify(json));
	         } catch (e) {
	        	 ThirdApp.alertinfo('初始化页标题栏异常' , 'initPageTitle:' + e);
	         }
		}else{
			if (ThirdApp.os == 'android') {
				var cfg = {
						title : "0",
						leftButton: {
							exist : "false",
							name : "",
							func : ""
						},
						rightButton: {
							exist : "false",
							name : "",
							func : ""
						},
						rightButton2: {
							exist : "false",
							name : "",
							func : ""
						}
					};
				window.SysClientJs.updateTitleInfo(ThirdApp.toJsonStr(cfg));
			} else if (ThirdApp.os == 'iphone') {
				setWebitEvent("ThirdApp._removeTitle()", "02");
			}
		}
		
	},
	
	_removeTitle : function(){
		var cfg = {
				title : "0",
				leftButton: {
					exist : "true",
					name : "",
					func : "backHome"
				},
				rightButton: {
					exist : "false",
					name : "",
					func : ""
				},
				rightButton2: {
					exist : "false",
					name : "",
					func : ""
				}
			};
		return ThirdApp.toJsonStr(cfg);
	},
	
	/**
	 * 5.0 by kangl
	 */
	_getPageTitle : function(pageId) {
		var page = $("#"+pageId);  //改成标准写法
		var cfg = {
			title : page.attr("title"),
			titleColor : page.attr("titleColor"),
			queryBack : page.attr("data-queryBack")
		};
		var leftCfg = page.attr("data-btnLeft").split("|");
		cfg.leftButton = this._generyTitleButton(leftCfg);
		var rightCfg = page.attr("data-btnRight").split("|");
		cfg.rightButton = this._generyTitleButton(rightCfg);
		var rightButton2=page.attr("data-btnRight2");
		if(rightButton2!=null&&rightButton2!=""){
			
			cfg.rightButton2 = this._generyTitleButton(rightButton2.split("|"));
		}
		return cfg;
	},
	/**
	 * 5.0 by kangl
	 */
	//设置安卓原生返回键返回方法
	setBackBtn : function(func){
		if (ThirdApp.os == 'android') {
			if(!func){
				func = "history.back()";
			}
			var cfg = {
					title : "",
					leftButton: {
						exist : "true",
						name : "",
						func : func
					},
					rightButton: {
						exist : "false",
						name : "",
						func : ""
					},
					rightButton2: {
						exist : "false",
						name : "",
						func : ""
					}
				};
			window.SysClientJs.updateTitleInfo(ThirdApp.toJsonStr(cfg));
		}
	},
	/**
	 * 5.0 by kangl
	 */
	_generyTitleButton : function(cfg) {
		if (cfg && cfg.length == 3) {
			return {
				exist : cfg[0],
				name : cfg[1],
				func : cfg[2]
			};
		}
		return {
			exist : false,
			name : "",
			func : ""
		};
	},
	/**
	 * 5.0 by kangl
	 */
	//调用拨打电话
	gotoCall : function(data) {
		if(ThirdApp.versionFiveFlag){
			try {
				var cfg={
						phoneNo:data,
				};
				ThirdApp._callHandler("callPhone", JSON.stringify(cfg));
			} catch (e) {
				ThirdApp.alertinfo('拨打电话异常', 'gotoCall:' + e);
			}
		}else{
			if (ThirdApp.os == 'android') {
				window.SysClientJs.gotoCall(m);
			} else if (ThirdApp.os == 'iphone') {
				try{
	            	_WK_DATAS["gotoCall"] = {
	                 		'tel' : m
	                    };
	            	setWebitEvent("_gotoCall()", "A9");
	            }catch(e){
	                alert(e);
	            }
			}
		}
		
	},
	/**
	 * 5.0 by kangl
	 */
	//获取手机号码
	getMobileNo: function(callback){
		if(ThirdApp.versionFiveFlag){
			try{
				callback = ThirdApp.getFunctionName(callback);
				var cfg={
						callback:callback,
					}
				ThirdApp._callHandler("getPhoneNumber", JSON.stringify(cfg));
			} catch (e) {
				ThirdApp.alertinfo('获取登录用户手机号异常','getPhoneNumber:' + e);
			}
		}else{
			if (ThirdApp.os == 'android') {
				window.SysClientJs.getMobileNo(func);
			} else if (ThirdApp.os == 'iphone') {
				try{
	            	_WK_DATAS["getMobileNo"] = { 'callback' : func };
	            	setWebitEvent("_getMobileNo()", "C1");
	            }catch(e){
	                alert(e);
	            }
			}
		}
		
	},
	//下载文件 5.0 by kangl
	downloadFile : function(url,name) {
		if(ThirdApp.versionFiveFlag){
			try {
				var cfg={
						 url:url,
		                 name:name,
				};
				ThirdApp._callHandler("downloadFile", JSON.stringify(cfg));
			} catch (e) {
				ThirdApp.alertinfo('获取理财说明证书异常', 'downloadFile:' + e);
			}
		}else{
			if (ThirdApp.os == 'android') {
				window.SysClientJs.downloadFile(url,name);
			} else if (ThirdApp.os == 'iphone') {
	            try{
	                _WK_DATAS["downloadFile"] = {
	                    url : url,
	                    name: name
	                };
	                setWebitEvent("_downloadFile()", "42");
	            }catch(e){
	                alert(e);
	            }			
			}
		}
		
	},
    //判断是否登录  5.0 by kangl
    isLogin : function(callback) {
    	if(ThirdApp.versionFiveFlag){
    		try {
    			var cfg={
    					callback:ThirdApp.getFunctionName(callback),
    			};
    			ThirdApp._callHandler("isLogin", JSON.stringify(cfg));
    		} catch (e) {
    			ThirdApp.alertinfo('判断是否登录异常', 'isLogin:' + e);
    		}
		}else{
			if (ThirdApp.os == 'android') {
				window.SysClientJs.isLogin(callback);
			} else if (ThirdApp.os == 'iphone') {
				try{
			        _WK_DATAS["isLogin"] = {callback:callback};
			        setWebitEvent("_getIsLogin()", "34");
	            }catch(e){
	                alert(e);
	            }
			}
		}
		
	},
    //获取客户号 5.0 by kangl
    getCustNo : function(callback){
    	if(ThirdApp.versionFiveFlag){
    		try{
    			callback = ThirdApp.getFunctionName(callback);
    			var cfg={
    					callback:callback,
    				}
    			if (ThirdApp.os == 'android') {
    				ThirdApp._callHandler("getCustNo", JSON.stringify(cfg));
    			} else if (ThirdApp.os == 'iphone') {
    				ThirdApp._callHandler("getcoreCustNo", JSON.stringify(cfg));
    			}
    			
    		} catch (e) {
    			ThirdApp.alertinfo('获取核心客户号异常' , 'getcoreCustNo:' + e);
    		}
		}else{
			if (ThirdApp.os == 'android') {
				window.SysClientJs.getCustNo(callback);
			} else if (ThirdApp.os == 'iphone') {
				try{
			        _WK_DATAS["getCustNo"] = {callback:callback};
			        setWebitEvent("_getCustNo()", "C2");
	            }catch(e){
	                alert(e);
	            }
			}
		}
		
	},
    /**
     * 5.0 by kangl
     */
    //微信分享 content-分享文字内容  url-地址url imgUrl-图片Url
    wxShare : function(txt,url,imgUrl){
    	if(ThirdApp.versionFiveFlag){
    		try {
    			// 获取回调函数方法名
    			var cfg = {
    				type : "WX,PYQ",// 分享渠道
    				// WX-微信，PYQ-朋友圈，QQ-qq，WB-微博，DX-短信，YX-邮箱
    				title : txt,// 分享标题
    				content :"",// 分享摘要
    				hrefUrl : url,// 分享url地址
    				imgUrl : imgUrl,// 分享图片url地址
    				callback : "",// 回调函数
    				shareType:"Image", //分享类型：Image代表图片形式分享  WebPage代表网页形式
    			}
    			ThirdApp._callHandler("sharePages", JSON.stringify(cfg));
    		} catch (e) {
    			ThirdApp.alertinfo('页面分享异常', 'sharePages:' + e);
    		}
		}else{
			if (ThirdApp.os == 'android') {
	    		window.SysClientJs.shareWeb(content,url,imgUrl);
	    	} else if (ThirdApp.os == 'iphone') {
	    		try{
	    			var data = {
							'txt' : content,
							'url' : url,
							'imgUrl' : imgUrl
					};
					
	                _WK_DATAS["shareWeb"] = data;
	                		
	                setWebitEvent("_shareWeb()", "D20");
	    		}catch(e){
	    			alert(e);
	    		}
	    	}
		}
		
    },
	/**
	 * 保持会话，直接调用无返回 5.0 by kangl
	 */
	keepSession : function() {
		if(ThirdApp.versionFiveFlag){
			try {
				ThirdApp._callHandler("keepSession", {});
			} catch (e) {
				ThirdApp.alertinfo('保持手机银行session异常', 'keepSession:' + e);
			}
		}else{
			if (ThirdApp.os == 'android') {
				window.SysClientJs.heartbeat();
			} else if (ThirdApp.os == 'iphone') {
				setWebitEvent("{'ss':''}", 'C7');
			}
		}
		
	},
	//弹框提示 5.0 by kangl
	alertinfo : function(msg, title, okAct, okName) {
		if(ThirdApp.versionFiveFlag){
			try {
				okAct = ThirdApp.getFunctionName(okAct);
				if (okAct && okAct.substr(okAct.length - 1) != ")") {
					okAct = okAct + "()";
				}
				var regex=/\((.+?)\)/g;
//				var code=msg.match(regex);
				var code=regex.exec(msg);
				var newType=code==null?"4":"15";
				title = title || "温馨提示";
				okName = okName || "确定";
				var cfg = {
					title : title,
					info : msg,
					ok_text : okName,
					ok_func : okAct || "",
					type : newType 
				};
				var cfg_tmp = {
					alertType:"showNormalAlert",
					alertInfo:JSON.stringify(cfg),
				};
				ThirdApp._callHandler("alertinfo", JSON.stringify(cfg_tmp));
			} catch (e) {
				alert('alertinfo:' + e);
			}
			
		}else{
			var a = {
					title : "温馨提示",
					info : msg,
					type : "4",
					imageFlag : "2",
					ok_text : "确定",
					ok_func : "",
					cancel_text : "",
					cancel_func : ""
				};
				if (ThirdApp.os == 'android') {
					window.SysClientJs.alertinfo(ThirdApp.toJsonStr(a));
				} else if (ThirdApp.os == 'iphone') {
					_WK_DATAS["thirdAlert"] = ThirdApp.toJsonStr(a);
					setWebitEvent("_getAlertInfo()", "25");
				}
		}
		
	},

	/**
	 * 解析JSON，兼容不支持JSON对象的浏览器
	 * 
	 * @param str
	 * @returns
	 */
	parseJson : function(str) {
		var obj;
		try {
			obj = JSON.parse(str);
		} catch (e) {
			obj = eval("(" + str + ")");
		}
		return obj;
	},
	/**
	 * 将对象转换成json字符串
	 * 
	 * @param obj
	 */
	toJsonStr : function(obj) {
		if(JSON.stringify){
			return JSON.stringify(obj);
		}
		if (obj == null) {
			return '""';
		}
		switch (typeof (obj)) {
			default: 
			case 'number':
			case 'string':
				return '"' + obj + '"';
			case 'object': {
				if (obj instanceof Array) {
					var strArr = [];
					var len = obj.length;
					for ( var i = 0; i < len; i++) {
						strArr.push(ThirdApp.toJsonStr(obj[i]));
					}
					return '[' + strArr.join(',') + ']';
				} else {
					var arr = [];
					for ( var i in obj) {
						arr.push('"' + i + '":' + ThirdApp.toJsonStr(obj[i]));
					}
					return "{" + arr.join(',') + "}";
				}
			}
		}
		return '""';
	},

	/**
	 * App对象初始化
	 */
	init : function() {
		ThirdApp.checkOs();
	},
	checkOs : function() {
		var ua = navigator.userAgent;
		var p = navigator.platform;// 检测平台
		if (ua.indexOf('Android') > -1) {
			ThirdApp.os = "android";
		} else if (ua.indexOf('iPhone') > -1) {
			ThirdApp.os = "iphone";
		} else {
			ThirdApp.os = "web";
		}
		
		if (ThirdApp.os == 'iphone') {
			var W = window;
			W._mevents = new Array();
			W._ajaxArray = new Array();
			W.setWebitEvent = function(evtName, evtCode) {
				if (evtName == "") {
					return;
				}
				_mevents.push({
					code : evtCode,
					name : evtName
				});
			};
			// iphone调用获取EventCode
			W.getWebkitEventCode = function() {
				return _mevents.length > 0 ? ThirdApp.toJsonStr(_mevents.shift()) : "0";
			};
			// 获取自定义事件
			W.getWebkitEvent = function() {
				return "";
			};
			W._WK_DATAS = [];
			
			W._WK_DATAS["wait"] = {'msg':'','callback':'','touchable':'false'};
			W.showWaitPanel = function() {
				return ThirdApp.toJsonStr(_WK_DATAS["wait"]);
			};
			W.closeWaitPanel = function() {
				_WK_DATAS["wait"] = {};
			};
			
			W._getVersion = function(){
		    	return ThirdApp.toJsonStr(_WK_DATAS["getVersion"]);
		    };
		    
		 // 获取登陆成功后续跳转的url
			W._getThirdLoginInfo = function() {
				return ThirdApp.toJsonStr(_WK_DATAS["thirdLogin"]);
			};
			
			// 获取通讯录
			W._getContact = function() {
				return ThirdApp.toJsonStr(_WK_DATAS["getContact"]);
			};
		    
		 // 获取支付数据
			W._getThirdPayInfo = function() {
				return _WK_DATAS["thirdPay"];
			};
			
			W._getCustInfo = function() {
				return ThirdApp.toJsonStr(_WK_DATAS["custInfo"]);
			};
		    W._toHomePage = function(){
		    	return ThirdApp.toJsonStr(_WK_DATAS["toHomePage"]);
		    };
		 // 获取通讯录
		    W._gotoCall = function(){
		    	return ThirdApp.toJsonStr(_WK_DATAS["gotoCall"]);
		    };
		    //获取手机号码
		    W._getMobileNo = function(){
		    	return ThirdApp.toJsonStr(_WK_DATAS["getMobileNo"]);
		    };
		    W._downloadFile = function(){
		    	  return ThirdApp.toJsonStr(_WK_DATAS["downloadFile"]);
		    };
			W._ZXLoginStatus = function(){
		    	return ThirdApp.toJsonStr(_WK_DATAS["ZXLoginStatus"]);
		    };
		    W._openZxyh = function(){
		    	return ThirdApp.toJsonStr(_WK_DATAS["openZxyh"]);
		    };
		    W._getLocation = function(){
		    	return ThirdApp.toJsonStr(_WK_DATAS["getLocation"]);
		    };
			W._getIsLogin = function(){
		        return ThirdApp.toJsonStr(_WK_DATAS["isLogin"]);
		    };
		    W._getCustNo =  function(){
		    	  return ThirdApp.toJsonStr(_WK_DATAS["getCustNo"]);
		    };	
		    W._shareWeb = function() {
				return ThirdApp.toJsonStr(_WK_DATAS["shareWeb"]);
			};
			W._loadThirdUrl = function(){
				return ThirdApp.toJsonStr(_WK_DATAS["loadThirdUrl"]);
			};
			W._wechatShare = function() {
				return JSON.stringify(_WK_DATAS["wechatShare"]);
			};
			W._loginStatus = function(){
		    	return ThirdApp.toJsonStr(_WK_DATAS["loginStatus"]);
		    };
		  //判断是否iphoneX
		      W._isIphoneX = function(){
		       return ThirdApp.toJsonStr(_WK_DATAS["isIphoneX"]);
		      };
		}
			
			
		//入口只有一个地方的 可以使用		
//		var args = ThirdApp.getArgs();
//		var clientVersion = args["clientVersion"];
//		if(clientVersion == "five"){
//			ThirdApp.versionFiveFlag = true;
//			//获取版本号
//		}else{
//			ThirdApp.versionFiveFlag = false;
//		}

		//入口不止一个地方  且不固定的
	try{
		ThirdApp.getVersion4("ThirdApp.getSjyhAppVersion");
	}catch(e){
		ThirdApp.getVersion("ThirdApp.getSjyhAppVersion");
	}
			
	},
	
	getSjyhAppVersion: function(v){
		var ver_reg = /^5.*/;
		if(ver_reg.test(v)){
			ThirdApp.versionFiveFlag = true;
		}else{
			ThirdApp.versionFiveFlag = false;
		}
	},
	
	AJKGotoLogin :function(callback){
		if(ThirdApp.versionFiveFlag){
			var cfg={
					callback:ThirdApp.getFunctionName(callback),
			};
			ThirdApp._callHandler("AJKGotoLogin", JSON.stringify(cfg));
		}else{
			if (ThirdApp.os == 'android') {
				window.SysClientJs.gotoLoginFromAJK('jsyhLoginCallBack');
	    	} else if (ThirdApp.os == 'iphone') {
	    		window._mevents=window._mevents||[];
				window._jsyhLoginCallBack=function(){
					return JSON.stringify( {"callback" : "jsyhLoginCallBack"} )
				}
				_mevents.push({
					name : "_jsyhLoginCallBack()",
					code : "AI36"
				});
	    	}
		}
	},
	
	/**
	 * @description 截屏分享<br>
	 *              接口名称：shareReceipt <br>
	 * @param {json}
	 *            type 分享参数
	 * @param {function}
	 *            callback 回调函数名称
	 * @example YT.Client.shareReceipt1(data,callback);
	 */
	shareReceipt1 : function(type, callback,needLogin){
		if(ThirdApp.versionFiveFlag){
			try {
				// 获取回调函数方法名
				callback = ThirdApp.getFunctionName(callback);
				var cfg = {
					type : type,
					callback : callback,
					needLogin:needLogin,
				};
				ThirdApp._callHandler("shareReceipt", JSON.stringify(cfg));
			} catch (e) {
				ThirdApp.alertinfo('分享图片信息异常', 'shareReceipt:' + e);
			}
		}else{
			//4.0的按照原来的加进来
		}
	},
	
	getWalkingSteps : function(callback) {
		if(ThirdApp.versionFiveFlag){
			try {
				var cfg={
						callback : ThirdApp.getFunctionName(callback),
				};
				ThirdApp._callHandler("getWalkingSteps", JSON.stringify(cfg));
			} catch (e) {
				ThirdApp.alertinfo('获取步数异常', 'getWalkingSteps:' + e);
			}
		}else{
			if (os == 'android') {
				window.SysClientJs.getStepToday('appCallbackGetStep2');
			} else if (os == 'iphone') {
				_WK_DATAS["appCallbackGetStep2"] = {
					callback : 'appCallbackGetStep2',
				};
				setWebitEvent("_appCallbackGetStep2()", "JSB04006");
				// alert("执行iPhone获取app步数2");
			}
		}
	},
	
	/**
	 * @description 获取客户端信息<br>
	 *              接口名称：getClientInfo <br>
	 * @param {function}
	 *            callback 回调函数
	 * @example YT.Client.getClientInfo(callback);
	 */
	getClientInfo : function(callback) {
		if(ThirdApp.versionFiveFlag){
			try {
				callback = ThirdApp.getFunctionName(callback);
				var cfg = {
					callback : callback,
				};
				ThirdApp._callHandler("jspbGetClientInfo", JSON.stringify(cfg));
			} catch (e) {
				ThirdApp.alertinfo('获取客户端信息组件异常', '_jspbGetClientInfo:' + e);
			}
		}else{
			if (os == 'android') {
				window.SysClientJs.getClientInfo('shareCallback');
			} else if (os == 'iphone') {
				if(window.CONSTANT_CONFIG.logincnl==1){

		            _WK_DATAS["clientData"] = {
		                callback : 'shareCallback',
		            };

		            setWebitEvent("_clientData()", "C16");
		        }else if(window.CONSTANT_CONFIG.logincnl==2){
		            // _WK_DATAS["shareMsg"] = {
		            //     shareMsg:shareMsg,
		            //     shareUrl:shareUrl,
		            //     data: shareData
		            // };
		            // setWebitEvent("_setShareMsg()", "24");
				}
			}
		}
	},
	
	getArgs : function() {
        // 加上substring的意义是去掉查询字符串中的？号。
        // var query = window.location.search.substring(1);

        // 定义一个数组，用于存放取出来的字符串参数。
        var argsArr = new Object();

        // 获取URL中的查询字符串参数
        var query = window.location.search;
        query = query.substring(1);

        // 这里的pairs是一个字符串数组
        var pairs = query.split("&");// name=myname&password=1234&sex=male&address=nanjing

        for (var i = 0; i < pairs.length; i++) {
            var sign = pairs[i].indexOf("=");
            // 如果没有找到=号，那么就跳过，跳到下一个字符串（下一个循环）。
            if (sign == -1) {
                continue;
            }

            var aKey = pairs[i].substring(0, sign);
            var aValue = pairs[i].substring(sign + 1);

            argsArr[aKey] = decodeURI(aValue);
        }
        return argsArr;
    },
	
	getFvVsCb :function(v){
		if(v){
			ThirdApp.appVersion = v.replace(/(^\s*)|(\s*$)/g,"").replace(/\./g,"");
			if(1*ThirdApp.appVersion>499){ //5.0
				ThirdApp.versionFiveFlag = true;
			}else{ //4.0
				ThirdApp.versionFiveFlag = false;
			}
			//	ThirdApp.removeNativeTitle();	  //用三方自己头部 放开
		}else{
			ThirdApp.alertinfo('获取版本号失败', 'getVersion Error');
		}
	},
	
	
	getVsCb : function(v){
		if(v){
			ThirdApp.appVersion = v.replace(/(^\s*)|(\s*$)/g,"").replace(/\./g,"");
			if(1*ThirdApp.appVersion>499){ //5.0
				ThirdApp.versionFiveFlag = true;
			}else{ //4.0
				ThirdApp.versionFiveFlag = false;
			}
			//	ThirdApp.removeNativeTitle();	  //用三方自己头部 放开
		}else{
			ThirdApp.alertinfo('获取版本号失败', 'getVersion Error');
		}
	},
	
	/**
	 * @description  判断当前设备是否是iPhoneX<br>
	 * *
	 * @example YT.Client.isIPhoneX(callback);
	 */
	isIphoneX :function(callback){
		if(ThirdApp.versionFiveFlag){
			try{
				callback = ThirdApp.getFunctionName(callback);
				var cfg={
						callback:callback,
					}
				ThirdApp._callHandler("isIPhoneX",JSON.stringify(cfg));
			} catch (e) {
				ThirdApp.alertinfo('判断当前设备是否是iPhoneX异常', 'isIPhoneX:' + e);
			}
		}else{
			if (ThirdApp.os == 'android') {

			  } else if (ThirdApp.os == 'iphone') {
			   try{
			             _WK_DATAS["isIphoneX"] = {
			                   'callback' : callback
			                    };
			             setWebitEvent("_isIphoneX()", "JSBN10");
			            }catch(e){
			                alert(e);
			            }
			  }

		}
	},
	
	//权益平台 5.0 没找到对应方法  ??
	wechatShare: function(shareMsg,shareTitle,shareType,shareUrl,imgUrl,picBase64,callback){
		if(ThirdApp.versionFiveFlag){
			try {
				// 获取回调函数方法名
				callback = ThirdApp.getFunctionName(callback);
				var cfg = {
					type : "",// 分享渠道 
					// WX-微信，PYQ-朋友圈，QQ-qq，WB-微博，DX-短信，YX-邮箱
					title : shareTitle,// 分享标题
					content : shareMsg,// 分享摘要
					hrefUrl : shareUrl,// 分享url地址
					imgUrl : imgUrl,// 分享图片url地址
					callback : callback,// 回调函数
					shareType:shareType, //分享类型：Image代表图片形式分享  WebPage代表网页形式
					picBase64:picBase64
				}
				ThirdApp._callHandler("sharePages", JSON.stringify(cfg));
			} catch (e) {
				ThirdApp.alertinfo('页面分享异常', 'sharePages:' + e);
			}
		}else{
			if (ThirdApp.os == 'android') {
				window.SysClientJs.wechatShare(shareMsg,shareTitle,shareType,shareUrl,imgUrl,picBase64,callback);
			} else if (ThirdApp.os == 'iphone') {
	            try{
	            	var data = {
							'shareMsg' : shareMsg,
							'shareTitle': shareTitle,
							'shareType' : shareType,
							'shareUrl' : shareUrl,
							'imgUrl' : imgUrl,
							'picBase64' : picBase64,
							'callback' : callback
					};
					
	                _WK_DATAS["wechatShare"] = data;
	                		
	                setWebitEvent("_wechatShare()", "JSB04008");

	            }catch(e){
	                alert(e);
	            }			
			}
		}
		
	},
	/**
	 *  5.0 by kangl
	 */
	openThirdTagUrl: function(url,local,title) {
		if(ThirdApp.versionFiveFlag){
			try {
				var cfg={
						url : url,
	             		local : local,
	             		title : title
				};
				ThirdApp._callHandler("loadThirdUrl", JSON.stringify(cfg));
			} catch (e) {
				ThirdApp.alertinfo('跳转第三方页面异常', 'loadThirdUrl:' + e);
			}
		}else{
			if (ThirdApp.os == 'android') {
				window.SysClientJs.openThirdTagUrl(url);
			} else if (ThirdApp.os == 'iphone') {
	            try{
	            	_WK_DATAS["loadThirdUrl"] = {
	             		'url' : "qypt",
	             		'local' : "1",
	             		'title' : "在线客服"
	                };
	    			setWebitEvent("_loadThirdUrl()", "C5");
	            }catch(e){
	                alert(e);
	            }			
			}
		}
		
	},
	
	// extend.js start
	/**
		 * 获取客户信息
		 * 调用方式：ThirdApp.getCustInfo(callback);
		 * @param callback 直销页面js回调方法名，客户信息作为参数传入callback
		 * @return
		 */
		getCustInfo : function(callback) {
			if(ThirdApp.versionFiveFlag){
				try {
					var cfg={
							callback:ThirdApp.getFunctionName(callback),
					};
					ThirdApp._callHandler("directBankVerification", JSON.stringify(cfg));
				} catch (e) {
					ThirdApp.alertinfo('直销银行登录判断异常', 'directBankVerification:' + e);
				}
			}else{
				if (ThirdApp.os == 'android') {
					window.SysClientJs.ZXLogin(callback);
				} else if (ThirdApp.os == 'iphone') {
					var data = {
							'callback' : callback,
					};
					_WK_DATAS["custInfo"] = data;
					setWebitEvent('_getCustInfo()', 'C6');
				}
			}
		},
		
		/**
		 * 获取直销银行登录状态
		 * ThirdApp.setLoginStatus(status)
		 * 直销登录成功或退出时将登录状态传入手机银行客户端 1：已经登录；0：退出登录；
		 */
		setLoginStatus: function(s){
			if(ThirdApp.versionFiveFlag){
				try {
					var cfg={
							status:s,
					};
					ThirdApp._callHandler("directBankStatus", JSON.stringify(cfg));
				} catch (e) {
					ThirdApp.alertinfo('直销银行登录标识异常', 'directBankStatus:' + e);
				}
			}else{
				if (ThirdApp.os == 'android') {
					window.SysClientJs.setZXStatus(s);
				} else if (ThirdApp.os == 'iphone') {
					var data = {
							'status' : s,
					};
					_WK_DATAS["ZXLoginStatus"] = data;
					setWebitEvent('_ZXLoginStatus()', 'C8');
				}
			}
		},
		
		/**
		 * 登录状态
		 * 
		 */
		getLoginStatus: function(cb){
			if(ThirdApp.versionFiveFlag){
				var cfg={
						url:"cust/getCustinfo.do",  //???
						callback:cb,
					}
				ThirdApp._callHandler("post", JSON.stringify(cfg));
			}else{
				  if (ThirdApp.os == 'android') {
					  window.SysClientJs.WebReqInfo("/normal/acctListQuery.do?met=getFreezingStatus",cb);
				  } else if (ThirdApp.os == 'iphone') {
				   setWebitEvent("ThirdApp._getLoginStatus('" + cb + "')", "JSB20");
				  }
			}
			  
		},
		_getLoginStatus: function(cb){
		  return ThirdApp.toJsonStr({url:"/normal/acctListQuery.do?met=getFreezingStatus",callback:cb});
		 },
		
		/**
		 * ios打开直销银行方法（解决ios10兼容问题）
		 */
		openZxyh: function(){
			if(ThirdApp.versionFiveFlag){
				try {
					var cfg={
							url:"jsbczxyh://mybank.jsbchina.zxyh",
					};
					ThirdApp._callHandler("openDirectBank", JSON.stringify(cfg));
				} catch (e) {
					ThirdApp.alertinfo('客户端打开直销银行app异常', 'openDirectBank:' + e);
				}
			}else{
				var data = {
						'url' : 'jsbczxyh://mybank.jsbchina.zxyh',
				};
				_WK_DATAS["openZxyh"] = data;
				setWebitEvent('_openZxyh()', 'C9');
			}
		},
		// extend.js end	
		
		// extendJs.js start
		goMsgList : function(type){
			var url = "../myMessage/myMessage.html?type="+type+"&os="+ThirdApp.os;
			document.location.href = url;
		},
		// extendJs.js end
		
		// sjyh_ccy.js start
		/**
		 *  initPageTitle
		 */
		setTitle : function(titleStr,callback){
			if(!callback){
				callback = "history.back()";
			}
			if(ThirdApp.versionFiveFlag){
				try {
					var json = this._getPageTitleCCY(titleStr,callback);
					ThirdApp._callHandler("initPageTitle", JSON.stringify(json));
				} catch (e) {
					ThirdApp.alertinfo('初始化页标题栏异常', 'initPageTitle:' + e);
				}
			}else{
				var cfg = {
						title : titleStr,
						leftButton: { exist : "true", name : "", func : callback },
						rightButton: {exist : "false", name : "", func : ""}
					};
				if (ThirdApp.os == 'android') {
					window.SysClientJs.updateTitleInfo(ThirdApp.toJsonStr(cfg));
				} else if (ThirdApp.os == 'iphone') {
					setWebitEvent("ThirdApp._getPageTitleCCY('" + titleStr +"','" + callback + "')", "02");
				}
			}
			
			ThirdApp.keepSession();
		},
		
		_getPageTitleCCY: function(titleStr,callback) {
			var cfg = {
					title : titleStr,
					leftButton: { exist : "true", name : "", func : callback },
					rightButton: {exist : "false", name : "", func : ""}
				};
			return ThirdApp.toJsonStr(cfg);
		},
		// sjyh_ccy.js end
		//sjyh_csh.js  start
		/**
		 * 获取支付签约状态，返回回调数据为json格式字符串{STATUS:"x",MSG:"xx"}，STATUS:1已签约，其他未签约
		 */
		getPaySignStatus: function(cb){
			if(ThirdApp.versionFiveFlag){
				var cfg={
						url:"commom/getSignStatus.do",
						callback:cb,
					}
				ThirdApp._callHandler("post", JSON.stringify(cfg));
			}else{
				if (ThirdApp.os == 'android') {
					window.SysClientJs.WebReqInfo("/normal/getSignStatus.do",cb);
				} else if (ThirdApp.os == 'iphone') {
					setWebitEvent("ThirdApp._getPayCb('" + cb + "')", "JSB20");
				}
			}
			
		},
		_getPayCb: function(cb){
			return ThirdApp.toJsonStr({url:"/normal/getSignStatus.do",callback:cb});
		},
		
		/**
		 * 打开支付签约页面,调用getPaySignStatus方法，结果为未签约时，
		 * 可以调用此方法，打开手机银行支付签约页面
		 */
		openSignPage: function(){
			if(ThirdApp.versionFiveFlag){
				try {
					var cfg = {
						url : "page/netPay/signPayment.html",
		    			local : "0",
		    			title : "网上支付快捷签约"
					};
					ThirdApp._callHandler("newWebview", JSON.stringify(cfg));
				} catch (e) {
					ThirdApp.alertinfo('获取客户端信息组件异常', "closeBottomMenu:" + e);
				}
			}else{
				if (ThirdApp.os == 'android') {
					window.SysClientJs.newWebview("page/netPay/signPayment.html","0","网上支付快捷签约");
				} else if (ThirdApp.os == 'iphone') {
					setWebitEvent("ThirdApp._openSignPage()", "JSB06");
				}
			}
			
		},
		_openSignPage: function(){
			return ThirdApp.toJsonStr({url:"page/netPay/signPayment.html",local : "0",title : "网上支付快捷签约"});
		},
		/**
		 * 跳转交罚缴费页面，需传入违规记录信息，为json格式字符串  5.0 没有  page/trafficFine/payment4csh.html这个地址对应5.0哪里？
		 * 
		 */
		toTrafficPay: function(d){
			if(ThirdApp.versionFiveFlag){
				try{
					var cfg={
							theThirdData : d,
							url : "page/trafficFine/payment4csh.html",
						}
					ThirdApp._callHandler("saveThirdDataAndJump",JSON.stringify(cfg));
				} catch (e) {
					ThirdApp.alertinfo('存储第三方数据并跳转特定页面异常', 'saveThirdDataAndJump:' + e);
				}
			}else{
				if (ThirdApp.os == 'android') {
					window.SysClientJs.newThirdPay("page/trafficFine/payment4csh.html",d);
				} else if (ThirdApp.os == 'iphone') {
					setWebitEvent("ThirdApp._toTrafficPay('" + d + "')", "JSB21");
				}
			}
		},
		_toTrafficPay: function(d){
			return ThirdApp.toJsonStr({url:"page/trafficFine/payment4csh.html",theThirdData:d});
		},
		/**
		 * 设置标题  02   --解决
		 */
		crowdFunding : function(btnFlag, titleStr){
			var cfg = {
					title : titleStr,
					leftButton: { exist : "true", name : "", func : "history.back()" },
					rightButton: {exist : "false", name : "", func : ""}
				};
			if(ThirdApp.versionFiveFlag){
				try {
					var json = ThirdApp.toJsonStr(cfg);
					ThirdApp._callHandler("initPageTitle", JSON.stringify(json));
				} catch (e) {
					ThirdApp.alertinfo('初始化页标题栏异常', 'initPageTitle:' + e);
				}
			}else{
				if (ThirdApp.os == 'android') {
					window.SysClientJs.updateTitleInfo(ThirdApp.toJsonStr(cfg));
				} else if (ThirdApp.os == 'iphone') {
					setWebitEvent("ThirdApp._getPageTitleCCY('" + titleStr + "')", "02");
				}
			}
			
			ThirdApp.keepSession();
		},
		/**
		 * 登录状态判断,cb 回调方法名，返回数据{"status":"登录状态"}  --1已登录，0-未登录
		 */
		isLogined: function(cb){
			if(ThirdApp.versionFiveFlag){
				try {
					var cfg={
							callback:ThirdApp.getFunctionName(cb),
					};
					ThirdApp._callHandler("isLogin", JSON.stringify(cfg));
				} catch (e) {
					ThirdApp.alertinfo('判断是否登录异常', 'isLogin:' + e);
				}
			}else{
				ThirdApp.cbName = cb;
				if (ThirdApp.os == 'android') {
					window.SysClientJs.isLogin("ThirdApp.callCb");
				} else if (ThirdApp.os == 'iphone') {
					_WK_DATAS["isLogin"] = {callback: "ThirdApp.callCb"};
			        setWebitEvent("_getIsLogin()", "34");
				}
			}
			
		},
		callCb: function(a){
			var fn = eval(ThirdApp.cbName);
			var rst = {"status": a}; 
			fn.call(this,ThirdApp.toJsonStr(rst));
		},
		getLocation: function(callback){//{"locality":"当前位置","longitude":"经度坐标","latitude":"纬度坐标","place":"地点" }
			if(ThirdApp.versionFiveFlag){
				try{
					callback = ThirdApp.getFunctionName(callback);
					var cfg={
							callback:callback,
						}
					ThirdApp._callHandler("cshCurrentLocation",JSON.stringify(cfg));
				} catch (e) {
					ThirdApp.alertinfo('获取当前地理位置异常', 'cshCurrentLocation:' + e);
				}
			}else{
				if (ThirdApp.os == 'android') {
					window.SysClientJs.CarLifeLoc(cb);
				} else if (ThirdApp.os == 'iphone') {
					_WK_DATAS["getLocation"] = {callback: cb};
			        setWebitEvent("_getLocation()", "JSB19");
				}
			}
		},
		startLogin: function(callback) {
			if(ThirdApp.versionFiveFlag){
				try{
					callback = ThirdApp.getFunctionName(callback);
					var cfg={
							callback:callback,
						}
					ThirdApp._callHandler("cshLogin",JSON.stringify(cfg));
				} catch (e) {
					ThirdApp.alertinfo('车生活调用登陆异常', 'cshLogin:' + e);
				}
			}else{
				if (ThirdApp.os == 'android') {
					window.SysClientJs.CarLifeLogin(cb);
				} else if (ThirdApp.os == 'iphone') {
					var data = {'callback' : cb};
					_WK_DATAS["custInfo"] = data;
					setWebitEvent('_getCustInfo()', 'JSB18');
				}
			}
		},
		//sjyh_csh.js  end
		//sjyh_zxkf.js  start
		checkPhonePermiss:function(callback){
			if(ThirdApp.versionFiveFlag){
				try{
					callback = ThirdApp.getFunctionName(callback);
					var cfg={
							callback:callback,
						}
					ThirdApp._callHandler("cameraAuthorizationStatus",JSON.stringify(cfg));
				} catch (e) {
					ThirdApp.alertinfo('相机权限异常', 'cameraAuthorizationStatus:' + e);
				}
			}else{
				if (ThirdApp.os == 'iphone') {
					_WK_DATAS["checkPhonePermiss"] = {
							'callback' : callback
			                };
					setWebitEvent("ThirdApp._checkPhonePermiss()", "JSBN07");
				}
			}
		},
		_checkPhonePermiss: function(){
			return ThirdApp.toJsonStr(_WK_DATAS["checkPhonePermiss"]);
		},
		loadThirdUrl: function(url,local,title){
			
			if(ThirdApp.versionFiveFlag){
				try {
					var cfg = {
						url : url,
		    			local : local,
		    			title : title
					};
					ThirdApp._callHandler("newWebview", JSON.stringify(cfg));
				} catch (e) {
					ThirdApp.alertinfo('获取客户端信息组件异常', "closeBottomMenu:" + e);
				}
			}else{
				if (ThirdApp.os == 'android') {
					window.SysClientJs.newWebview(url,local,title);
				} else if (ThirdApp.os == 'iphone') {
					_WK_DATAS["loadThirdUrl"] = {
			             		'url' : url,
			             		'local' : local,
			             		'title' : title
			                };
					setWebitEvent("ThirdApp._loadThirdUrl()", "JSB06");
				}
			}
		},
		_loadThirdUrl: function(){
			return ThirdApp.toJsonStr(_WK_DATAS["loadThirdUrl"]);
		},
		checkHaveBankApp : function() {
			var t=Date.now();
			window.location = "jsbsjyh://mbank.jsbchina.sjyh";
			setTimeout(function(){
				if(!t||Date.now()-t<1000){
					window.location = "http://m.jsbchina.cn";
					//alert("未安装此应用！");
				}
			},800);
		},
		audioStart: function(callback){
			if(ThirdApp.versionFiveFlag){
				try{
					callback = ThirdApp.getFunctionName(callback);
					var cfg = {
							callback : callback,
					};
					ThirdApp._callHandler("startAudioRecord",JSON.stringify(cfg));
				}catch (e){
					ThirdApp.alertinfo('获取客户端信息组件异常','startAudioRecord:' + e);
				}
			}else{
				if (ThirdApp.os == 'android') {
					   window.SysClientJs.audioStart(callback);
					  } else if (ThirdApp.os == 'iphone') {
						_WK_DATAS["audioStart"] = {
							'callback' : callback
						};
						setWebitEvent("ThirdApp._audioStart()", "JSB33");
					  }
			}
			  
		},
		_audioStart: function(){
			return ThirdApp.toJsonStr(_WK_DATAS["audioStart"]);
		},
		audioStop: function(callback){
			if(ThirdApp.versionFiveFlag){
				try{
					callback = ThirdApp.getFunctionName(callback);
					var cfg = {
							callback : callback,
					};
					ThirdApp._callHandler("stopAudioRecord",JSON.stringify(cfg));
				}catch (e){
					ThirdApp.alertinfo('获取客户端信息组件异常','stopAudioRecord:' + e);
				}
			}else{
				 if (ThirdApp.os == 'android') {
					   window.SysClientJs.audioStop(callback);
					  } else if (ThirdApp.os == 'iphone') {
					    _WK_DATAS["audioStop"] = {
							'callback' : callback
						};
						setWebitEvent("ThirdApp._audioStop()", "JSB34");
					  }
			}
			 
		},
		_audioStop: function(){
			return ThirdApp.toJsonStr(_WK_DATAS["audioStop"]);
		},
		audioCancel: function(){
				if(ThirdApp.versionFiveFlag){
					 try{
						 ThirdApp._callHandler("cancelAudioRecord");
						}catch (e){
							ThirdApp.alertinfo('获取客户端信息组件异常','cancelAudioRecord:' + e);
						}
				}else{
					if (ThirdApp.os == 'android') {
						   window.SysClientJs.audioCancel();
						  } else if (ThirdApp.os == 'iphone') {
						   setWebitEvent("ThirdApp._audioCancel()", "JSB35");
						  }
				}
		},
		_audioCancel: function(){
			return ThirdApp.toJsonStr(_WK_DATAS["audioCancel"]);
		},
		checkAudioPermission: function(callback){
				//1有权限0没有
			if(ThirdApp.versionFiveFlag){
				try{
					callback = ThirdApp.getFunctionName(callback);
					var cfg = {
							callback : callback,
					};
					ThirdApp._callHandler("checkMicrophonePermissions",JSON.stringify(cfg));
				}catch (e){
					ThirdApp.alertinfo('获取客户端信息组件异常','checkMicrophonePermissions:' + e);
				}
			}else{
				if (ThirdApp.os == 'android') {
					   window.SysClientJs.checkAudioPermission(callback);
					  } else if (ThirdApp.os == 'iphone') {
						 _WK_DATAS["checkAudioPermission"] = {
							'callback' : callback
						};
						setWebitEvent("ThirdApp._checkAudioPermission()", "JSB32");
					  }
			}  
			
		},
		_checkAudioPermission: function(){
			return ThirdApp.toJsonStr(_WK_DATAS["checkAudioPermission"]);
		},
		
		//sjyh_zxkf.js  end
		
		//云正通  start
		/***
		 * @description 云证通<br>
		 * 				接口名称：HKEInit<br>
		 * @param {function}
		 * 			info,callback,alertMsg
		 * @example YT.Client.HKEInit(info,callback,alertMsg);
		 */
	    HKEInit :function(info,callback,alertMsg){
			if(ThirdApp.versionFiveFlag){
				try {
		    		callback = ThirdApp.getFunctionName(callback);
					var cfg = {
						info : JSON.stringify(info),
		    			callback : callback,
		    			alertMsg : alertMsg
					};
					ThirdApp._callHandler("HKEInit", JSON.stringify(cfg));
				} catch (e) {
					ThirdApp.alertinfo('获取客户端信息组件异常', "HKEInit:" + e);
				}
			}else{
				if (ThirdApp.os == 'android') {
					window.SysClientJs.HKEInit(JsonToStr(info),callback,alertMsg);
				} else if (ThirdApp.os == 'iphone') {
					_WK_DATAS["HKEInit"] = {
			    			info : JsonToStr(info),
			    			callback : callback,
			    			alertMsg : alertMsg
			    		};
			        setWebitEvent("ThirdApp._HKEInit()", "JSB04"); 
				}
			}
	    },
	    
	    _HKEInit: function(){
			return ThirdApp.toJsonStr(_WK_DATAS["HKEInit"]);
		},
	    
	    
	    /***
		 * @description 云证通签名<br>
		 * 				接口名称：HKESign<br>
		 * @param {function}
		 * 			data,callback
		 * @example YT.Client.HKESign(data,callback);
		 */
	    HKESign: function(data,callback){
			if(ThirdApp.versionFiveFlag){
				try {
		    		callback = ThirdApp.getFunctionName(callback);
					var cfg = {
						businessText : data.businessText,
		    			businessTextSignature: data.businessTextSignature,
		    			callback : callback
					};
					ThirdApp._callHandler("HKESign", JSON.stringify(cfg));
				} catch (e) {
					ThirdApp.alertinfo('获取客户端信息组件异常', "HKESign:" + e);
				}
			}else{
			if (ThirdApp.os == 'android') {
				window.SysClientJs.HKESign(obj.businessText,obj.businessTextSignature,callback);
				} else if (ThirdApp.os == 'iphone') {
					_WK_DATAS["HKESign"] = {
			    			businessText : data.businessText,
			    			businessTextSignature: data.businessTextSignature,
			    			callback : callback
			    		};
			        setWebitEvent("ThirdApp._HKESign()", "JSB05"); 
				}
			}
	    },
		/**
		 * @description 签到<br>
		 */
		callUserSign : function() {
			try {
				var cfg = {
						isBackReload : isBackReload         // 签到返回是否刷新页面 0不刷新 1刷新
				};
				ThirdApp._callHandler("goSignIn", JSON.stringify(cfg));
			} catch (e) {
				ThirdApp.alertinfo('签到异常', 'goSignIn:' + e);
			}
		},
		/**
		 * @description 登录跳转<br>
		 */
		gotoHomePage : function(callback,url) {
			try {
				var cfg={
						callback : ThirdApp._callHandler.getFunctionName(callback),
						 url:url,
		                 msg:"",
		                 status:"0"
				};
					ThirdApp._callHandler("gotoLogin", JSON.stringify(cfg));
			} catch (e) {
				ThirdApp._callHandler.alertinfo('返回登录页面异常', 'gotoHomePage:' + e);
			}
		},
	    _HKESign: function(){
			return ThirdApp.toJsonStr(_WK_DATAS["HKESign"]);
		},
		
	    
	    /***
		 * @description 云证通验证<br>
		 * 				接口名称：HKECertStatus<br>
		 * @param {function}
		 * 			info,callback
		 * @example YT.Client.HKECertStatus(info,callback);
		 */
	    HKECertStatus :function(info,callback){
			if(ThirdApp.versionFiveFlag){
				try {
		    		callback = ThirdApp.getFunctionName(callback);
					var cfg = {
						info : JSON.stringify(info),
		    			callback : callback
					};
					ThirdApp._callHandler("HKECertStatus", JSON.stringify(cfg));
				} catch (e) {
					ThirdApp.alertinfo('获取客户端信息组件异常', "HKECertStatus:" + e);
				}
			}else{
			if (ThirdApp.os == 'android') {
				window.SysClientJs.HKECertStatus(JsonToStr(info),callback);
				} else if (ThirdApp.os == 'iphone') {
					_WK_DATAS["HKECertStatus"] = {
			    			info : JsonToStr(info),
			    			callback : callback
			    		};
			        setWebitEvent("ThirdApp._HKECertStatus()", "JSB37");	 
				}
			}
	    },
	    _HKECertStatus: function(){
			return ThirdApp.toJsonStr(_WK_DATAS["HKECertStatus"]);
		},
		//云正通  end
		
		 /**
		 * @description  调用人脸识别（新）<br>
		 * * @param {json}
		     *          cfg 
		 * @example YT.Client.toFaceCheck(data);
		 */
		toFaceCheck : function(cfg) {
			if(ThirdApp.versionFiveFlag){
				try {
					ThirdApp._callHandler("gotoFaceRecognition", JSON.stringify(cfg));
				} catch (e) {
					ThirdApp.alertinfo('上传身份证照片事件异常', 'toFaceCheck:' + e);
				}
			}else{
				if (ThirdApp.os == 'android') {
					window.SysClientJs.toFaceCheck(JsonToStr(cfg));  
				} else if (ThirdApp.os == 'iphone') {
					_WK_DATAS["faceCheckData"] = cfg;
					setWebitEvent("ThirdApp._toFaceCheck()", "54"); 
				}
			}
		},
		
		_toFaceCheck: function(){
			return ThirdApp.toJsonStr(_WK_DATAS["faceCheckData"]);
		},
		
		
		/***
		 * @description 车生活调用外部应用导航 JSB30<br>
		 * 				接口名称：mapNavigator<br>
		 * @param {function}
		 * 				
		 * @example YT.Client.mapNavigator();
		 */
		navigationApp : function(BDlonD,BDlatD,start,BDdataLon, BDdataLat,end,GCJlonD,GCJlatD,GCJdataLon,GCJdataLat) {
			if(ThirdApp.versionFiveFlag){
				try{
					var jsonInfo = {
							"BDlonD":	BDlonD,
							"BDlatD":	BDlatD,
							"locD": start,
							"BDdataLon": BDdataLon,
							"BDdataLat": BDdataLat,
							"dataLoc": end,
							"GCJlonD":	GCJlonD,
							"GCJlatD":	GCJlatD,
							"GCJdataLon": GCJdataLon,
							"GCJdataLat": GCJdataLat
						};
					ThirdApp._callHandler("mapNavigator",JSON.stringify(jsonInfo));
				}catch (e){
					ThirdApp.alertinfo('获取客户端信息组件异常','mapNavigator:' + e);
				}
			}else{
				if (ThirdApp.os == 'iphone') {
					var json = {
						"BDlonD":	BDlonD,
						"BDlatD":	BDlatD,
						"locD": start,
						"BDdataLon": BDdataLon,
						"BDdataLat": BDdataLat,
						"dataLoc": end,
						"GCJlonD":	GCJlonD,
						"GCJlatD":	GCJlatD,
						"GCJdataLon": GCJdataLon,
						"GCJdataLat": GCJdataLat
					};
					setWebitEvent(JSON.stringify(json), "JSB30");
				} else if (ThirdApp.os == 'android') {
					window.SysClientJs.getLocationInfo(BDlonD,BDlatD,start,BDdataLon,BDdataLat,end,GCJlonD,GCJlatD,GCJdataLon,GCJdataLat);
				}
			}
		},
		/**
		 * 移除原生头部标题   
		 */
		removeNativeTitle1: function(){
			if(ThirdApp.versionFiveFlag){
				 try {
					 var json = {
								title : "0",
								statusBarTextColor : "dark",
								leftButton: {
									exist : "false",
									name : "",
									func : ""
								},
								rightButton: {
									exist : "false",
									name : "",
									func : ""
								},
								rightButton2: {
									exist : "false",
									name : "",
									func : ""
								}
							};
					 ThirdApp._callHandler("initPageTitle", JSON.stringify(json));
		         } catch (e) {
		        	 ThirdApp.alertinfo('初始化页标题栏异常' , 'initPageTitle:' + e);
		         }
			}else{
				if (ThirdApp.os == 'android') {
					var cfg = {
							title : "0",
							leftButton: {
								exist : "false",
								name : "",
								func : ""
							},
							rightButton: {
								exist : "false",
								name : "",
								func : ""
							},
							rightButton2: {
								exist : "false",
								name : "",
								func : ""
							}
						};
					window.SysClientJs.updateTitleInfo(ThirdApp.toJsonStr(cfg));
				} else if (ThirdApp.os == 'iphone') {
					setWebitEvent("ThirdApp._removeTitle()", "02");
				}
			}
			
		}
		
};

ThirdApp.init();
